<?php
ini_set('display_errors', 0 );
error_reporting(0);
require_once('Connections/aciitu.php'); ?>
<?php
//MX Widgets3 include
require_once('includes/wdg/WDG.php');

if (!isset($_POST['categoria']) or $_POST['categoria'] == "") { $_POST['categoria'] = ""; }
if (!isset($_POST['estado']) or $_POST['estado'] == "") { $_POST['estado'] = ""; }
if (!isset($_POST['cidade']) or $_POST['cidade'] == "") { $_POST['cidade'] = ""; }
if (!isset($_POST['titulo']) or $_POST['titulo'] == "") { $_POST['titulo'] = ""; }

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_aciitu, $aciitu);
$query_RsCidImovel = "SELECT * FROM cidade ORDER BY nome ASC";
$RsCidImovel = mysql_query($query_RsCidImovel, $aciitu) or die(mysql_error());
$row_RsCidImovel = mysql_fetch_assoc($RsCidImovel);
$totalRows_RsCidImovel = mysql_num_rows($RsCidImovel);

mysql_select_db($database_aciitu, $aciitu);
$query_RsCateg = "SELECT * FROM categoria ORDER BY nome ASC";
$RsCateg = mysql_query($query_RsCateg, $aciitu) or die(mysql_error());
$row_RsCateg = mysql_fetch_assoc($RsCateg);
$totalRows_RsCateg = mysql_num_rows($RsCateg);

mysql_select_db($database_aciitu, $aciitu);
$query_RsEstado = "SELECT * FROM estado ORDER BY nome ASC";
$RsEstado = mysql_query($query_RsEstado, $aciitu) or die(mysql_error());
$row_RsEstado = mysql_fetch_assoc($RsEstado);
$totalRows_RsEstado = mysql_num_rows($RsEstado);

mysql_select_db($database_aciitu, $aciitu);
$query_Recordset1 = "SELECT  id, uf FROM estado ORDER BY uf";
$Recordset1 = mysql_query($query_Recordset1, $aciitu) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

mysql_select_db($database_aciitu, $aciitu);
$query_Recordset2 = "SELECT  id, estado_id, nome FROM cidade ORDER BY nome";
$Recordset2 = mysql_query($query_Recordset2, $aciitu) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wdg="http://ns.adobe.com/addt">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
-->
</style>
<script src="includes/common/js/base.js" type="text/javascript"></script>
<script src="includes/common/js/utility.js" type="text/javascript"></script>
<script type="text/javascript" src="includes/common/js/sigslot_core.js"></script>
<script type="text/javascript" src="includes/wdg/classes/MXWidgets.js"></script>
<script type="text/javascript" src="includes/wdg/classes/MXWidgets.js.php"></script>
<script type="text/javascript" src="includes/wdg/classes/JSRecordset.js"></script>
<script type="text/javascript" src="includes/wdg/classes/DependentDropdown.js"></script>
<?php
//begin JSRecordset
$jsObject_Recordset2 = new WDG_JsRecordset("Recordset2");
echo $jsObject_Recordset2->getOutput();
//end JSRecordset
?>
<link href="includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
</head>

<body>

<form action="filtro.php" method="post" name="buscar_imovel">

<table width="923" height="89" border="0" cellspacing="0" cellpadding="0" background="imagens/busca.png" style="background-repeat:no-repeat; background-position:top;">
  <tr>
    <td width="183" height="39">&nbsp;</td>
    <td width="146">&nbsp;</td>
    <td width="21">&nbsp;</td>
    <td width="77">&nbsp;</td>
    <td width="22">&nbsp;</td>
    <td width="146">&nbsp;</td>
    <td width="23">&nbsp;</td>
    <td width="216">&nbsp;</td>
    <td width="16">&nbsp;</td>
    <td width="46">&nbsp;</td>
    <td width="24">&nbsp;</td>
  </tr>
  <tr>
    <td height="26">&nbsp;</td>
    <td align="right">
    	<select name="categoria" id="categoria" style="font-size:11px; font-family:Arial; color:#ff6000; background:#F0F0F0; border:none; width:146px; height:24px;">
          <option value=""></option>
      <?php do { ?>
          <option value="<?php echo $row_RsCateg['id']; ?>" <?php if($row_RsCateg['id'] == $_POST['categoria']){ echo "selected='selected'"; } ?>><?php echo $row_RsCateg['nome']; ?></option>
        <?php } while ($row_RsCateg = mysql_fetch_assoc($RsCateg)); ?>
        </select>
    </td>
    <td>&nbsp;</td>
    <td align="right">
    
		<select name="estado" id="estado" style="font-size:11px; font-family:Arial; color:#ff6000; background:#F0F0F0; border:none; width:77px; height:24px;">
          <option value=""></option>
  <?php
do {  
?>
  <option value="<?php echo $row_Recordset1['id']?>"><?php echo $row_Recordset1['uf']?></option>
  <?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  $rows = mysql_num_rows($Recordset1);
  if($rows > 0) {
      mysql_data_seek($Recordset1, 0);
	  $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  }
?>
</select>
    </td>
    <td>&nbsp;</td>
    <td align="right">
    	<select wdg:subtype="DependentDropdown" wdg:type="widget" wdg:recordset="Recordset2" wdg:displayfield="nome" wdg:valuefield="id" wdg:fkey="estado_id" wdg:triggerobject="estado" name="cidade" id="cidade" style="font-size:11px; font-family:Arial; color:#ff6000; background:#F0F0F0; border:none; width:146px; height:24px;">
</select>
    </td>
    <td>&nbsp;</td>
    <td><input name="titulo" type="text" maxlength="50" <?php if($_POST['titulo'] <> ""){ echo "value=".$_POST['titulo']; } ?> style="font-size:11px; width:208px; border:none; color:#ff6000; background:none; height:24px; padding-left:4px; padding-right:4px;" /></td>
    <td>&nbsp;</td>
    <td><input type="submit" value="&nbsp;" title="Fazer Busca" style="background:none; border:none; width:46px; height:26px;" /></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="24">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

</form>

</body>
</html>
<?php
mysql_free_result($RsCidImovel);

mysql_free_result($RsCateg);

mysql_free_result($RsEstado);

mysql_free_result($Recordset1);

mysql_free_result($Recordset2);
?>
